<template>

  <div
    class="box"
    v-if="currentRoom.name"
  >
    <ChatArea
      class="chatarea"
      :room="currentRoom"
      :msgList="msgList"
    ></ChatArea>
    <InputArea
      class="inputarea"
      :room='currentRoom'
    ></InputArea>
  </div>
  <div v-else>
    <div class="card">
      <div class="additional">
        <div class="user-card">
          <div class="level center">
            {{userInfo.username}}
          </div>

          <template>
            <div class="user_pic">
              <img
                v-if="userInfo.user_pic"
                :src='userInfo.user_pic'
                alt=""
              > <img
                v-else
                src="../../../../assets/avatar1.svg"
                alt=""
              >
            </div>
          </template>

          <div class="points center">
            {{regTime}}
          </div>
        </div>
        <div class="more-info">
          <div class="stats">
            <div>
              <div class="title">发帖</div>
              <i class="fa fa-trophy"></i>
              <div class="value">{{userInfo.total_cards_number}}</div>
            </div>
            <div>
              <div class="title">回答</div>
              <i class="fa fa-gamepad"></i>
              <div class="value">{{userInfo.response_num}}</div>
            </div>
            <div>
              <div class="title">已注册</div>
              <i class="fa fa-group"></i>
              <div class="value">{{computedTime}}天</div>
            </div>

          </div>
        </div>
      </div>
      <div class="general">
        <div class="main">
          <div class="text">
            <h1>{{userInfo.username}}</h1>
            <p>{{userInfo.sign}}</p>

          </div>
          <div class="userinfo-foot">
            <div>
              <svg
                class="icon"
                aria-hidden="true"
              >
                <use xlink:href="#icon-gender"></use>
              </svg><span>{{userInfo.gender}}</span>
            </div>
            <div>
              <svg
                class="icon"
                aria-hidden="true"
              >
                <use xlink:href="#icon-ziyuan48"></use>
              </svg><span>{{userInfo.age}}</span>

            </div>
          </div>
        </div>

      </div>
    </div>
  </div>
</template>

 <script>
import ChatArea from "./ChatDetail";
import InputArea from "./InputArea/index.vue";
import { mapState } from "vuex";
export default {
  data() {
    return {};
  },
  components: {
    ChatArea,
    InputArea,
  },

  computed: {
    ...mapState({
      currentRoom: (state) => state.chat.currentRoomInfo,
    }),
    ...mapState({
      msgList: (state) => state.chat.messageList,
    }),
    ...mapState({
      userInfo: (state) => state.users.userInfo,
    }),
    regTime() {
      return this.$formatDate(this.userInfo.moment);
    },
    computedTime() {
      return this.$computedTime(this.userInfo.moment);
    },
  },
  mounted() {
    this.$store.dispatch("initUserInfo");
    console.log("交流圈的用户信息", this.userInfo);
  },
};
</script>

 

<style scoped lang='less'>
.box {
  display: flex;
  flex-flow: column;
  position: relative;
  justify-content: flex-start;
  width: 100%;
  height: 100%;

  .inputarea {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 200px;
  }

  .chatarea {
    width: 100%;
    height: 70%;
    flex: 1;
  }
}
.card {
  display: flex;
  width: 600px;
  height: 350px;
  background-color: #fff;
  background: linear-gradient(#f8f8f8, #fff);
  box-shadow: 0 8px 16px -8px rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  margin: 1.5rem;
}

.card h1 {
  text-align: center;
}

.card .additional {
  display: flex;
  position: absolute;
  width: 150px;
  height: 100%;
  background: linear-gradient(#de685e, #ee786e);
  transition: width 0.4s;
  overflow: hidden;
  z-index: 2;
}

.card.green .additional {
  background: linear-gradient(#92bca6, #a2ccb6);
}

.card:hover .additional {
  width: 100%;
  border-radius: 0 5px 5px 0;
}

.card .additional .user-card {
  display: flex;
  width: 150px;
  height: 100%;
  position: relative;
  float: left;
  flex-direction: column;
  justify-content: space-evenly;
  // justify-content: center;
  align-items: center;
}

.card .additional .user-card::after {
  content: "";
  display: block;
  position: absolute;
  top: 10%;
  right: -2px;
  height: 80%;
  border-left: 2px solid rgba(0, 0, 0, 0.025);
}

.card .additional .user-card .level,
.card .additional .user-card .points {
  top: 15%;
  color: #fff;
  text-transform: uppercase;
  font-size: 0.75em;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.125rem 0.75rem;
  border-radius: 100px;
  white-space: nowrap;
}

.card .additional .user-card .level {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1rem;
  width: 100px;
  text-align: center;
}
.card .additional .user-card .points {
  top: 85%;
}

.card .additional .user-card svg {
  top: 50%;
}

.card .additional .more-info {
  width: 300px;
  display: flex;
  float: left;
  position: absolute;
  left: 193px;
  height: 100%;
  justify-content: center;
  align-items: center;
}

.card .additional .stats {
  font-size: 2rem;
  width: 100%;
  display: flex;
  bottom: 1rem;
  top: auto;
  color: #fff;
}

.card.green .additional .stats {
  color: #325c46;
}

.card .additional .stats > div {
  flex: 1;
  text-align: center;
  margin-left: 20px;
}

.card .additional .stats i {
  padding: 10px;
  display: block;
}

.card .additional .stats div.title {
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
}

.card .additional .stats div.value {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1.5rem;
}

.card .additional .stats div.value.infinity {
  font-size: 2.5rem;
}

.card .general {
  display: flex;
  width: 300px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  position: absolute;
  top: 0;
  right: 13%;
  z-index: 1;
  box-sizing: border-box;
  padding: 1rem;
  padding-top: 0;
  padding-right: 1.5rem;
}
.main {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  position: relative;
  width: 100%;
  height: 80%;
}
.text {
  display: flex;
  position: absolute;
  top: 15%;
  flex-direction: column;
}
.text > h1 {
  margin-bottom: 1rem;
}

.icon {
  width: 30px;
  height: 30px;
}
.userinfo-foot {
  opacity: 0.5;
  display: flex;
  position: absolute;
  bottom: -10%;
  width: 100%;
}
.userinfo-foot > div {
  display: flex;
  text-align: center;
  justify-content: center;
  align-items: center;
  width: 50%;
}
.userinfo-foot > div > span {
  padding: 0 10px;
}
.editInfo {
  right: 0;
  bottom: 20px;
  margin-bottom: 5%;
}

/*头像 */

.form-control {
  display: flex;
  justify-content: center;
  flex-direction: column;
}

.avatar {
  margin-top: 1rem;
  width: 400px;
}
.avatar span {
  margin-top: 5px;
}
.avatar .avatars {
  width: 100%;
  min-height: 60%;
  border: 10px solid #667aff;
  border-radius: 20px;
  list-style: none;
  padding: 10px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: repeat(2, 1fr);
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  justify-items: center;
  align-items: center;
  box-sizing: border-box;
}
.avatar .avatars li {
  height: 4rem;
  margin-bottom: 0.2rem;
  cursor: pointer;
  border-radius: 28px;
  overflow: hidden;
  box-sizing: border-box;
  box-sizing: border-box;
}

.avatar .avatars li img {
  width: 4rem;
}
.active {
  transition: all 0.1s;
  border: 4px solid #f7c924;
}
.the_img {
  width: 150px;
  height: 150px;
  border-radius: 100px;
  border: 5px solid #f7c924;
}
.pre_img {
  display: flex;
  justify-content: center;
  align-items: center;
}
/*头像按钮 */
.btn-box {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
.user_pic {
  width: 140px;
  height: 140px;
  overflow: hidden;
  border-radius: 50%;
  border: 2px solid #fceeb5;
}
.user_pic > img {
  width: 100%;
  height: 100%;
}

/*个签 */
.sign {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
}

.submit-btn {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
}
.userWords {
  display: flex;
  background-color: #acdccec3;
  margin-top: 4px;
  width: 100%;
  height: 150px;
  padding: 10px;
  justify-content: center;
  align-items: center;
  position: relative;
  box-sizing: border-box;
  font-family: cursive;
  font-size: 20px;
  border-radius: 10px;
  background: #fff;
  background-image: linear-gradient(#f5f5f0 1.1rem, #ccc 1.2rem);
  background-size: 100% 1.2rem;
  line-height: 1.45rem;
  padding: 0.5rem 0.2rem 0.1rem 0.1rem;
  margin-top: 10px;
}
/* textarea */
.message {
  background: none;
  /* border: none; */
  border: none;
  resize: none;
  outline: none;
  box-sizing: border-box;
  padding: 8px;
  width: 100%;
  height: 100%;
  margin-top: 12px;
}

.userWords > span {
  width: 96%;
  height: 90%;
  overflow: auto; /* 溢出隐藏 */
  text-align: center;
}
/*定义滚动条宽度和颜色*/

::v-deep .el-drawer__body::-webkit-scrollbar {
  width: 7px;
}

::v-deep .el-drawer__body::-webkit-scrollbar-track {
  background: #d2f3ef;
}

::v-deep .el-drawer__body::-webkit-scrollbar-thumb {
  background: #94f0f0;
}

/* 悬停效果 */
::v-deep .el-drawer__body::-webkit-scrollbar-thumb:hover {
  background: #5cd0f4;
}

.userWords-span::-webkit-scrollbar {
  width: 4px;
}

.userWords-span::-webkit-scrollbar-track {
  background: #d2f3ef;
}

.userWords-span::-webkit-scrollbar-thumb {
  background: #94f0f0;
}

/* 悬停效果 */
.userWords-span::-webkit-scrollbar-thumb:hover {
  background: #5cd0f4;
}

/* 结束 */
</style>